<?php

class ForumModel extends BaseForumModel{

	/**
	 * 
	 * Gets the URL.
	 */
	public function getURL(){
		return Module::get('Forum')->linkTo(array('f',$this->id, urlencode($this->name)));
	}
	
	public function threadCount(){
		return count($this->ForumThreads);
	}
	
	/**
	 * 
	 * Gets all the threads for a forum. Including the first id of thread posts so you can count them.
	 */
	public function getThreads(){
		$q = Doctrine_Query::create()
		->select('ft.id, ft.title,
		fp.id
		')
		->from('ForumThread ft')
		->innerJoin('ft.ThreadPosts tp')
		->where('ft.forum_id = ?', $this->id);
		
		return $q->execute();		
	}
}
